package com.schooleducation.controller.teacher;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.schooleducation.entity.Lesson;
import com.schooleducation.entity.User;
import com.schooleducation.service.ServiceFactory;

@Controller
@RequestMapping("/teacher/resourceUpload")
public class resourceUploadController {

	@Resource(name = "serviceFac")
	private ServiceFactory serviceFac;

	@RequestMapping(method = RequestMethod.GET)
	public String getPage(Model model, HttpSession session) {
		User teacher = (User) session.getAttribute("teacher");
		if (teacher != null) {
			List<Lesson> list = serviceFac.getLessonService().getLessonListByTeacher(teacher);
			model.addAttribute("teacher", teacher);
			model.addAttribute("lessonList", list);
			
			return "teacher/resourceUpload";
		} else {
			return "redirect:../login";
		}
	}
}
